﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApplication1
{
    class SensorDllCall
    {
        public delegate void SensorInfo(double netWeight, double tare, double grossweight, int mode, int decimalDigit, int unitChar,
                            int oldAd, int filterAd, int zeroAd, int weightAd, int flag);
        public delegate void IS1Info(string status, string sign, string weight, string fUnit, int flag);

        [DllImport("SensorDll.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public extern static bool __Open(string commName, int baudRate);

        [DllImport("SensorDll.dll")]
        public extern static bool __Close();

        [DllImport("SensorDll.dll")]
        public extern static string __GetWeight();

        [DllImport("SensorDll.dll")]
        public extern static bool __GetWeightEx(ref StringBuilder ret);

        [DllImport("SensorDll.dll")]
        public extern static bool __Weight(string id);
        [DllImport("SensorDll.dll")]
        public extern static bool __SetUnitValue(UInt16 value, string Id);

        [DllImport("SensorDll.dll")]
        public extern static bool __Zero(string id);

        [DllImport("SensorDll.dll")]
        public extern static bool __Tare(string id);

        [DllImport("SensorDll.dll")]
        public extern static void __SetCallBackFunc(string funcId, Delegate funcInfo);

        [DllImport("SensorDll.dll")]
        public extern static bool __ChangeProtocol(UInt16 value);

        [DllImport("SensorDll.dll")]
        public extern static bool __EnumUsbDeviceStr(ref StringBuilder devs);

        [DllImport("SensorDll.dll")]
        public extern static bool __SetCommMode(UInt16 iMode);

        [DllImport("SensorDll.dll")]
        public extern static bool __SetUsbDeviceStr(string sDev);
        [DllImport("SensorDll.dll")]
        public extern static string __udeWeight(); 
    }
}
